<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="utn.frd.domain.Persona" %>

<%
List<Persona> personas = new ArrayList<Persona>();

if( request.getAttribute("persons") != null ){
	personas = (List<Persona>)request.getAttribute("persons");
}

%>
<html>
<head>
	<link type="text/css" rel="stylesheet" href="css/default.css">
</head>
<body>	
	<form name="formAction" method="post" action="formPersona"> 
		<table>
			<tr>
				<td>Nombre:</td>
				<td><input type="text" name="name"></td>
			</tr>
			<tr>
				<td>DNI:</td>
				<td><input type="text" name="dni"></td>
			</tr>
			<tr>
				<td>Edad:</td>
				<td><input type="text" name="age"></td>
			</tr>
			<tr>
				<td>Ciudad:</td>
				<td><input type="text" name="city"></td>
			</tr>
		</table>
		<input type="submit" value="Submit">
		<input type="reset" value="Reset">
	</form>
	
	<% if(request.getAttribute("error")!=null) { %>
	<div class="error">Error: <%= request.getAttribute("error") %></div>
	<% } %>
	
  	<table border=1px>
  		<thead>
  			<tr>
  				<th colspan="4">Datos</th>
  			</tr>
  			<tr>
  				<th>Nombre</th>
  				<th>DNI</th>
  				<th>Edad</th>
  				<th>Ciudad</th>
  			</tr>
  		</thead>
  		<tbody>
  	<% for(Persona person : personas ){ %>
		    <tr>
		      <td><%=person.getNombre()%></td>
		      <td><%=person.getDNI()%></td>
		      <td><%=person.getEdad()%></td>
		      <td><%=person.getCiudad()%></td>
		    </tr>
	<%} %>
  		</tbody>
  	</table>
</body>
</html>
